package com.tsystems.skilltest.processor;

import com.tsystems.skilltest.Transaction;

/**
 * @author aesipov
 */
public class TransactionProcessorDecider implements TransactionProcessor
{
    private TransactionProcessor positiveProcessor;
    private TransactionProcessor negativeProcessor;

    public TransactionProcessorDecider(TransactionProcessor positiveProcessor, TransactionProcessor negativeProcessor) {
        this.positiveProcessor = positiveProcessor;
        this.negativeProcessor = negativeProcessor;
    }

    public void process(Transaction transaction)
    {
        if (transaction.getValue() >= 0)
        {
            positiveProcessor.process(transaction);
        }
        else
        {
            negativeProcessor.process(transaction);
        }
    }
}
